<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php /** @var $this \Magento\AdminNotification\Block\ToolbarEntry */ ?>
<?php $notificationCount = $this->getUnreadNotificationCount(); ?>
<div class="notifications-summary" data-notification-count="<?php echo $this->escapeHtml($notificationCount); ?>">
    <?php if ($notificationCount > 0) : ?>
        <a href="<?php echo $this->getUrl('adminhtml/notification/index'); ?>" class="action notifications-action" title="<?php echo __('Notifications'); ?>" data-toggle="dropdown">
            <span class="text"><?php echo __('Notifications'); ?></span>
            <span class="counter qty"><?php echo $this->escapeHtml($notificationCount); ?></span>
        </a>
        <ul class="dropdown-menu notifications-list" data-mark-as-read-url="<?php echo $this->getUrl('adminhtml/notification/ajaxMarkAsRead'); ?>">
            <?php foreach ($this->getLatestUnreadNotifications() as $notification) : ?>
            <?php /** @var $notification \Magento\AdminNotification\Model\Inbox*/ ?>
            <li class="notifications-entry<?php if ($notification->getSeverity() == 1): ?> notifications-critical<?php endif; ?>"
                data-notification-id="<?php echo $this->escapeHtml($notification->getId()); ?>"
                data-notification-severity="<?php if ($notification->getSeverity() == 1): ?>1<?php endif; ?>">
                <strong class="notifications-entry-title"><?php echo $this->escapeHtml($notification->getTitle()); ?></strong>
                <span class="notifications-entry-description"><?php echo $this->escapeHtml($notification->getDescription()); ?></span>
                <time class="notifications-entry-time"><?php echo $this->escapeHtml($this->formatNotificationDate($notification->getDateAdded())); ?></time>
                <button class="action close notifications-close"><span><?php echo __('Close'); ?></span></button>
                <div class="notifications-dialog-content" data-title="<?php echo __('Notification'); ?>" data-cancel-caption="<?php echo  __('Cancel'); ?>" data-acknowledge-caption="<?php echo __('Acknowledge'); ?>">
                    <strong class="notifications-entry-title"><?php echo $this->escapeHtml($notification->getTitle()); ?></strong>
                    <span class="notifications-entry-description"><?php echo $this->escapeHtml($notification->getDescription()); ?></span>
                    <div class="actions notifications-entry-actions">
                        <a class="notifications-url" href="<?php echo $this->escapeUrl($notification->getUrl()); ?>" target="_blank"><?php echo __('Read Details'); ?></a>
                    </div>
                    <time class="notifications-entry-time"><?php echo $this->escapeHtml($this->formatNotificationDate($notification->getDateAdded())); ?></time>
                </div>
            </li>
            <?php endforeach; ?>
            <li class="last">
                <a href="<?php echo $this->getUrl('adminhtml/notification/index'); ?>" class="action more notification-more"><?php echo __('See All (%1 unread)', $notificationCount); ?></a>
            </li>
        </ul>
    <?php else : ?>
        <a href="<?php echo $this->getUrl('adminhtml/notification/index'); ?>" class="action notifications-action empty" title="<?php echo __('Notifications'); ?>">
            <span class="text"><?php echo __('Notifications'); ?></span>
        </a>
    <?php endif; ?>
</div>
